<?php

/**
 * FootballFactory, Copyright Robin Loop & Pascal Wirz, 2014
 * ---
 * Template zum Auflisten der Spiele
 *
 * @author Robin
 */

require('templates/header.php');
?>
<html>
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <!-- JQuery -->
        <script src="../js/jquery-1.8.3.min.js"></script>
        <script src="../js/jquery-ui-1.9.2.custom.min.js"></script>
        
        <!-- JS -->
        <script src="../js/admin_menu.js"></script>
        <script src="../js/admin_game.js"></script> 
        
        <!-- CSS -->
        <link href="../css/admin.css" rel="stylesheet">
        <link href="../css/smoothness/jquery-ui-1.9.2.custom.css" rel="stylesheet">
        
    </head>

    <body>
        
        <?php include 'menu.php'; ?>
        
        <div>
            <h1>Spiele</h1>
                
            <div>
		<p>
                    <select id="teamlist">
                        <option value="-1" <?php if ($teamId == -1) { echo "selected"; } else { echo ""; } ?>>Alle Teams</option>
			<?php foreach ($teams as $team) { ?>
			<option value="<?php echo $team->getId(); ?>" <?php if ($team->getId() == $teamId) { echo "selected"; } else { echo ""; } ?>><?php echo $team->getName(); ?></option>
        		<?php } ?>
                    </select>
                    <select id="seasonlist">
                        <option value="-1" <?php if ($seasonId == -1) { echo "selected"; } else { echo ""; } ?>>Alle Saisons</option>
			<?php foreach ($seasons as $season) { ?>
			<option value="<?php echo $season->getId(); ?>" <?php if ($season->getId() == $seasonId) { echo "selected"; } else { echo ""; } ?>><?php echo $season->getName(); ?></option>
			<?php } ?>
                    </select>
                </p>
				
                <table>
                    <tr>
                      <th>ID</th>
                      <th>Heimteam</th>
                      <th>Auswärtsteam</th>
                      <th>Datum</th>
					  <th>Typ</th>
                      <th>GH</th>
                      <th>GA</th>
                      <th>Team</th>
                      <th>Saison</th>
                      <th>Ort</th>
                      <th></th>
                      <th></th>
                    </tr>
                    <?php foreach ($games as $game) { ?>
                    <tr>
                        <td><?php echo $game->getId()?></td>
                        <td><?php echo $game->getHometeam()?></td>
                        <td><?php echo $game->getAwayteam()?></td>
                        <td><?php echo date('d.m.Y', strtotime($game->getDate()))?></td>
                        <td><?php echo $game->getType()?></td>
                        <td><?php echo $game->getGoalshome()?></td>
                        <td><?php echo $game->getGoalsaway()?></td>
                        <td><?php echo $game->getTeam()?></td>
                        <td><?php echo $game->getSeason()?></td>
                        <td><?php echo $game->getVenue()?></td>
                        <td><a href="game.php?action=edit&amp;gameId=<?php echo $game->getId()?>">editieren</a></td>
                        <td><!--<a href="game.php?action=delete&amp;gameId=<?php echo $game->getId()?>" onclick="return confirm('Spiel loeschen?')">loeschen</a>--></td>
                    </tr>  
                    <?php } ?>
                </table>
                <p>Anzahl Spiele: <?php echo $numbGames ?></p>
                <p><a href="game.php?action=new">Neues Spiel erfassen</a></p>
            </div>
        </div>
    </body>
</html>